var url = require('url');
var util = require('util');
var configServer = require('./configServer');
var fs = require('fs');
var test = require('../test/test');

var route = function(req, res) {
	res.writeHeader(200, {
		"Content-type": "text/plain;charset=utf8"
	})

	var urlParse = url.parse(req.url, true);
	var query = urlParse.query;
	var pathname = urlParse.pathname;
	console.log("路由为：" + pathname)
	switch (pathname) {
		case "/": // 微信公众号配置服务器：请填写接口配置信息，此信息需要你有自己的服务器资源，填写的URL需要正确响应微信发送的Token验证
			configServer(req, res, query);
			break
		case "/fs":
			test.fs(req, res);
			break;
		
		case "/token":
			test.get_access_token(req, res);
			break;
		default:
			var obj = {
				pathname: pathname,
				query: query,
				doc: "你的url是什么呢？看看了。。。"
			}
			var log = util.inspect(obj);
			console.log(log);
			res.end(log)
	}
}

module.exports = route;
